<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateShopGoods extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('shop_goods',['engine'=>'InnoDB'])->setComment('商城-商品');
        $table->addColumn(Column::integer('sid')->setDefault(0)->setComment('商家id'));
        $table->addColumn(Column::string('spec_id')->setNullable()->setComment('规格id'));
        $table->addColumn(Column::char('cate_id',30)->setNullable()->setComment('分类id'));
        $table->addColumn(Column::char('tags_id',30)->setNullable()->setComment('商品标签id'));
        $table->addColumn(Column::tinyInteger('type')->setDefault(1)->setComment('商品类型 1:普通商品'));
        $table->addColumn(Column::string('title')->setComment('商品名称'));
        $table->addColumn(Column::string('mini_title')->setNullable()->setComment('商品副标题'));
        $table->addColumn(Column::string('logo',500)->setNullable()->setComment('商品LOGO'));
        $table->addColumn(Column::string('adv_img',500)->setNullable()->setComment('广告图'));
        $table->addColumn(Column::string('image',500)->setNullable()->setComment('商品图片地址'));
        $table->addColumn(Column::string('video',500)->setNullable()->setComment('商品视频URL'));
        $table->addColumn(Column::text('spec')->setNullable()->setComment('规格组'));
        $table->addColumn(Column::decimal('price',10,2)->setDefault(0)->setComment('最低价格'));
        $table->addColumn(Column::decimal('price_express',10,2)->setDefault(0)->setComment('商品运费'));
        $table->addColumn(Column::text('content')->setNullable()->setComment('商品内容'));
        $table->addColumn(Column::tinyInteger('reco_status')->setDefault(0)->setComment('是否是推荐商品:1是，0否'));
        $table->addColumn(Column::tinyInteger('hots_status')->setDefault(0)->setComment('是否是热销产品:1是，0否'));
        $table->addColumn(Column::integer('read_num')->setDefault(0)->setComment('商品访问量'));
        $table->addColumn(Column::integer('sort')->setDefault(0)->setComment('排序'));
        $table->addColumn(Column::tinyInteger('status')->setDefault(1)->setComment('状态(0:禁用,1:启用)'));
        $table->addColumn(Column::tinyInteger('is_deleted')->setDefault(0)->setComment('删除(1:删除,0:未删)'));
        $table->addTimestamps('create_at');
        $table->create();
    }
}
